#include <string.h>
#include <strings.h>
#include "lws_utils.h"
#include "lws_hmm.h"

using namespace LWS;

int main(int argc, char *argv[])
{
    if(argc < 3)
    {
	printf("trainhmm -tp <corpus_intputfile> <start_and_trans_outputfile> "
		"<emit_outputbinfile> <emit_outputtxtfile> <person_name_outputfile>\n");
	printf("Sample: trainhmm -tp ./corpus/corpus.txt ./data/person_start_and_trans.txt "
		"./data/person_emit.dat ./data/person_emit.txt ./corpus/person_name.txt\n");
	printf("trainhmm -lp <corpus_intputfile> <start_and_trans_outputfile> "
		"<emit_outputbinfile> <emit_outputtxtfile> <location_name_outputfile>\n");
	printf("Sample: trainhmm -lp ./word/corpus.txt ./data/location_start_and_trans.txt "
		"./data/location_emit.dat ./data/location_emit.txt ./corpus/location_name.txt\n");
	printf("trainhmm -pp <word_inputfile> <postag_inputfile> <corpus_intputfile> "
		"<start_and_trans_outputfile> <emit_outputbinfile> <emit_outputtxtfile>\n");
	printf("Sample: trainhmm -pp ./corpus/word.txt ./corpus/postag.txt ./corpus/corpus.txt "
		"./data/postag_start_and_trans.txt ./data/postag_emit.dat ./data/postag_emit.txt\n");
	return -1;
    }
    
    if(strncasecmp(argv[1], "-tp", strlen("-tp")) == 0 && argc == 7) {
	CTrainPerson tp(6769, 10);
	tp.TrainStartAndTrans(argv[2]);
	tp.TrainEmit(argv[2]);
	tp.OutputStartAndTrans(argv[3]);
	tp.OutputEmit(argv[4], argv[5]);
	tp.Output(argv[6]);
    } else if(strncasecmp(argv[1], "-lp", strlen("-lp")) == 0 && argc == 7) {
	CTrainLocation lp(6769, 6);
	lp.TrainStartAndTrans(argv[2]);
	lp.TrainEmit(argv[2]);
	lp.OutputStartAndTrans(argv[3]);
	lp.OutputEmit(argv[4], argv[5]);
	lp.Output(argv[6]);
    } else if(strncasecmp(argv[1], "-pp", strlen("-pp")) == 0 && argc == 8) {
	CTrainPosTag pp(argv[2], argv[3], 238961, 40);
	pp.TrainStartAndTrans(argv[4]);
	pp.TrainEmit(argv[4]);
	pp.OutputStartAndTrans(argv[5]);
	pp.OutputEmit(argv[6], argv[7]);
    }
}
